import {lazy} from "react";
import {Navigate} from "react-router-dom";
import Main from '../componets/Main'
import Home from '../componets/Main/Home'
import Error from '../componets/404'

const Login = lazy(() => import("../componets/Login"));
const Users = lazy(() => import("../componets/Main/Users"));
const System = lazy(() => import('../componets/Main/System'))
const Task = lazy(() => import('../componets/Main/Task'))
const TaskEdit = lazy(() => import('../componets/Main/Task/TaskEdit'))
const TaskSuiteEdit = lazy(() => import('../componets/Main/Task/TaskEdit/TaskSuiteEdit'))
const Interface = lazy(() => import('../componets/Main/Interface'))
const EditInterFaces = lazy(() => import('../componets/Main/Interface/EditInterFaces'))
const SystemModule = lazy(() => import('../componets/Main/Interface/SystemModule'))
const Links = lazy(() => import('../componets/Main/Links'))
const Environment = lazy(() => import('../componets/Main/System/Environment'))
const GrantSystem = lazy(() => import('../componets/Main/GrantSystem'))
const TaskReport = lazy(() => import('../componets/Main/TaskReport'))
const TaskRecord = lazy(() => import('../componets/Main/TaskRecord'))
const InterFaceRecordList = lazy(() => import('../componets/Main/TaskReport/InterFaceRecordList'))
const InterfaceRecordDetails = lazy(() => import('../componets/Main/TaskReport/InterFaceRecordList/InterfaceRecordDetails'))

const routes = [
    {
        path: '/login',
        element: <Login/>
    },
    {
        path: '/main',
        element: <Main/>,
        children: [
            {
                path: 'users',
                element: <Users/>
            },
            {
                path: 'editSystem',
                element: <System/>,
            },
            {
                path: 'task',
                element: <Task/>
            },
            {
                path: 'editTask/:id',
                element: <TaskEdit/>
            },
            {
                path: 'editTaskSuit/:system_id/:task_id',
                element: <TaskSuiteEdit/>
            },
            {
                path: "environment/:id",
                element: <Environment/>
            },
            {
                path: "interfaces",
                element: <Interface/>
            },
            {
                path: "editInterfaces/:id",
                element: <EditInterFaces/>
            },
            {
                path: "systemModule/:id",
                element: <SystemModule/>
            },
            {
                path: 'links',
                element: <Links/>
            },
            {
                path: 'grantSystem',
                element: <GrantSystem/>
            },
            {
                path: 'detail',
                element: <TaskReport/>
            },
            {
                path: 'taskRecord',
                element: <TaskRecord/>
            },
            {
                path: 'interFaceRecordList/:id',
                element: <InterFaceRecordList/>
            },
            {
                path: 'interfaceRecordDetails/:systemId/:id',
                element: <InterfaceRecordDetails/>
            },
            {
                path: '',
                element: <Home/>
            }
        ]
    },
    {
        path: '/',
        element: <Navigate to='/login'/>
    },
    {
        path: '*',
        element: <Error/>
    }
]

export default routes